<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Models\SystemStore;
use Illuminate\Http\Request;
use Mockery\Exception;

class SystemStoreController extends Controller
{
    /**
     * 门店列表
     * @return array
     */
    public function index()
    {
        try {
            $result = SystemStore::list();
            return success('数据查询成功', $result);
        } catch (\Exception $exception) {
            return fails($exception->getMessage(), '');
        }
    }

    /**
     * 门店详情
     * @param Request $request
     * @return array
     */
    public function rand(Request $request)
    {
        $id = $request->get('id');
        //参数判断
        if (!is_numeric($id) || $id == '') {
            return fails('参数格式不正确', '');
        }
        try {
            $result = SystemStore::read($id);
            return success('数据获取成功', $result);
        } catch (\Exception $exception) {
            return fails($exception->getMessage(), '');
        }
    }
}
